const state = {
    searchForm: {
        OverviewIndex: {},
        OverviewListIndex: {},
        OverviewListInfo: {},
        OverviewCover: {},
        OverviewDeathsIndex: {},
        OverviewDeathsInfo: {},
        OverviewAgainIndex: {},
        OverviewAgainInfo: {},
        ImportMRIndexDRG: {},
        ImportMRListIndexDRG: {},
        ImportMRListInfoDRG: {},
        MRListIndexDRG: {},
        MRListInfoDRG: {},
        Drgs: {},
        NormalIndex: {},
        NormalInfo: {},
        NotIncludedIndex: {},
        NotIncludedInfo: {},
        ExcludeGroupIndex: {},
        ExcludeGroupInfo: {},
        Safety: {},
        SafetyListIndex: {},
        SafetyListInfo: {},
        Efficiency: {},
        EfficiencyListIndex: {},
        EfficiencyListInfo: {},
        Service: {},
        ServiceListIndex: {},
        ServiceListInfo: {},
        Expenses: {},
        ExpensesListIndex: {},
        ExpensesListInfo: {},
        ImportSettle: {},
        CompareResultsIndex: {},
        CompareResultsInfo: {},
        BillingListIndex: {},
        BillingListInfo: {}
    }
}

const mutations = {
    SET_SEARCH_FORM_ITEM: (state, form) => {
        state.searchForm[form.pageName] = form.query
    },
    COVER_SEARCH_FORM_ITEM: (state, form) => {
        state.searchForm[form.pageName] = form.query
    },
    SET_SEARCH_FORM: (state, form) => {
        state.searchForm = form
    },
    CLEAR_ALL: (state, name) => {
        Object.keys(state.searchForm).forEach(key => {
            if (key !== name) {
                state.searchForm[key] = {}
            }
        })
    }
}

const actions = {
    setSearchFormItem ({ commit }, form) {
        commit('SET_SEARCH_FORM_ITEM', form)
    },
    coverSearchFormItem ({ commit }, form) {
        commit('COVER_SEARCH_FORM_ITEM', form)
    },
    setSearchForm ({ commit }, form) {
        commit('SET_SEARCH_FORM', form)
    },
    clearAll ({ commit }, name) {
        commit('CLEAR_ALL', name)
    }
}

export default {
    namespaced: true,
    state,
    mutations,
    actions
}
